package com.ahncnk.powermonitor.admin.users.service;

import com.ahncnk.powermonitor.admin.users.domain.entity.User;
import com.ahncnk.powermonitor.admin.users.repository.UserRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Optional;

/**
 * UserService
 *
 * @author lipei
 */
@Service
public class UserService {
    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Resource
    private UserRepository userRepository;

    public Optional<User> findByUsername(String username){
        return userRepository.findByUsername(username);
    }


    @Scheduled(cron = "*/5 * * * * ?")
    public void jobExample(){
        logger.info("定时任务执行 - {}", LocalDateTime.now());
    }
}
